find duplicate elements in array using brute force